import { useMemo } from 'react'
import { axisTypes } from '@/pages/bi-core/utils/const'

function useTooltip(chart, type) {
  const { tooltipEnabled } = chart
  const tooltip = useMemo(() => {
    const show = tooltipEnabled
    if (!tooltipEnabled) return { show }
    return { show, trigger: axisTypes.includes(type) ? 'axis' : 'item' }
  }, [tooltipEnabled])

  return { tooltip }
}

export default useTooltip
